<?php

/**
 * Description of v
 * 
 * @author 叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 */

namespace c\info;

class v extends g
{
    function index_home()
    {
        $id = intval($_GET['id']);
        $d = $this->db->getOne($this->table, '*', 'id='.$id);
        $this->isExist($d);
        $this->db->upField($this->table, 'hits', $id);

        //seo
        $this->title = $d['title'];
        $d['keywords'] && $this->t_var['seo']['keywords'] = $d['keywords'];
        
        //content
        $dc = $this->db->get_page(array('limit'=>1),'info_content', '*', 'info_id='. $id, 'page');
        if ($dc)
            $content = $dc[0]['content'];
        else
            $content = '';
        
		//nav 
		$this->t_var['nav'] = $this->S->pNav($sid);
		
		//echo
        $this->t_var['data'] = $d;
        $this->loadTemplate('info/view', array('content'=>$content));
        $this->loadLayout('info');
    }
	
	function index_list()
	{
		$sid = intval($_GET['id']);
		$d = $this->S->getOne($sid);
		$this->isExist($d['state']);
		$this->t_var['sdata'] = $d;
		
		//nav
		$this->t_var['nav'] = $this->S->pNav($sid);
		
		//res
		//$hasS = $this->db->get($this->S->table, '*', 'parent_id='. $sid);
		if ($hasS)
		 {
			$this->loadLayout($d['layout_id'] ? $d['layout_id'] : 'info_sort');
		 }
		else{
			$t = array('t1'=>array('as'=>$this->table),
						'sm'=>array('as'=>$this->table_sortMap, 'join'=>'JOIN','on'=>'sm.data_id=t1.id'));
			$w = "sm.sort_id IN($sid) AND t1.state>0 ";
			$res = $this->db->get_page(array(), $t, '*', $w, 'id DESC');
			$this->loadTemplate('info/list', array('res'=>$res));
			
			$this->loadLayout($d['layout_id'] ? $d['layout_id'] :'info_list');
		 }
	}
}
